import 'package:wanxiang_app/generated/json/base/json_convert_content.dart';
import 'package:wanxiang_app/bean/price_entity.dart';

PriceEntity $PriceEntityFromJson(Map<String, dynamic> json) {
  final PriceEntity priceEntity = PriceEntity();
  final int? code = jsonConvert.convert<int>(json['code']);
  if (code != null) {
    priceEntity.code = code;
  }
  final String? msg = jsonConvert.convert<String>(json['msg']);
  if (msg != null) {
    priceEntity.msg = msg;
  }
  final List<PriceData>? data = (json['data'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<PriceData>(e) as PriceData).toList();
  if (data != null) {
    priceEntity.data = data;
  }
  return priceEntity;
}

Map<String, dynamic> $PriceEntityToJson(PriceEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['code'] = entity.code;
  data['msg'] = entity.msg;
  data['data'] = entity.data.map((v) => v.toJson()).toList();
  return data;
}

extension PriceEntityExtension on PriceEntity {
  PriceEntity copyWith({
    int? code,
    String? msg,
    List<PriceData>? data,
  }) {
    return PriceEntity()
      ..code = code ?? this.code
      ..msg = msg ?? this.msg
      ..data = data ?? this.data;
  }
}

PriceData $PriceDataFromJson(Map<String, dynamic> json) {
  final PriceData priceData = PriceData();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    priceData.id = id;
  }
  final String? sortId = jsonConvert.convert<String>(json['sort_id']);
  if (sortId != null) {
    priceData.sortId = sortId;
  }
  final String? bprice = jsonConvert.convert<String>(json['bprice']);
  if (bprice != null) {
    priceData.bprice = bprice;
  }
  final String? eprice = jsonConvert.convert<String>(json['eprice']);
  if (eprice != null) {
    priceData.eprice = eprice;
  }
  final String? content = jsonConvert.convert<String>(json['content']);
  if (content != null) {
    priceData.content = content;
  }
  return priceData;
}

Map<String, dynamic> $PriceDataToJson(PriceData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['sort_id'] = entity.sortId;
  data['bprice'] = entity.bprice;
  data['eprice'] = entity.eprice;
  data['content'] = entity.content;
  return data;
}

extension PriceDataExtension on PriceData {
  PriceData copyWith({
    String? id,
    String? sortId,
    String? bprice,
    String? eprice,
    String? content,
  }) {
    return PriceData()
      ..id = id ?? this.id
      ..sortId = sortId ?? this.sortId
      ..bprice = bprice ?? this.bprice
      ..eprice = eprice ?? this.eprice
      ..content = content ?? this.content;
  }
}